package view.game
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import flash3.framework.IUpdate;
	import flash3.framework.Layer;
	import flash3.net.NetFacade;
	
	import net.*;
	
	import util.SoundManager;
	public class GameBase extends Layer
	{
		protected var timeOutCount:uint;
		protected var gameView:GameView = null;
		public function GameBase()
		{
			super();
		}
		
		override public function enter():void
		{
			NetFacade.i.acall(TableGroup.MDM_GR_STATUS, TableGroup.SUB_GR_TABLE_STATUS, {call:netNofityTableStatus,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_SEND_CARD, {call:netNofitySendCard,forever:true});
			NetFacade.i.acall(UserGroup.MDM_GR_USER, UserGroup.SUB_GR_USER_STATUS, {call:netNofityUserStatus,forever:true});
			NetFacade.i.acall(UserGroup.MDM_GR_USER, UserGroup.SUB_GR_USER_SCORE, {call:netNofityUserScore,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_LAND_SCORE, {call:netNofityLandScore,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_PASS_CARD, {call:netNofityPassCard,forever:true});
			
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_GAME_START, {call:netNofityGameStart,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_DOUBLE_SCORE, {call:netNofityDoubleScore,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_OUT_CARD, {call:netNofityOutCard,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_GAME_END, {call:netNofityGameEnd,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_USER_DOUBLE, {call:netNofityUserDouble,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_BRIGHT_CARD, {call:netNofityBrightCard,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_BRIGHT_START, {call:netNofityBrightStart,forever:true});
			NetFacade.i.acall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_MULTIPLE, {call:netNofityMultiple,forever:true});
			NetFacade.i.acall(UserGroup.MDM_GR_USER,UserGroup.SUB_GR_USER_SUPPLY_APPLY_SUC,{call:netNotifyUserSupplyApplySuc,forever:true});
			NetFacade.i.acall(RoomGroup.MDM_GR_SERVER_INFO,RoomGroup.SUB_GR_RUNINFO,{call:netReplyRunInfo,forever:true});
			NetFacade.i.acall(UserGroup.MDM_GR_USER,UserGroup.SUB_GR_USER_SUPPLY_NEED,{call:netNotifyUserSupplyNeed,forever:true});
			NetFacade.i.acall(UserGroup.MDM_GR_USER,UserGroup.SUB_GR_USER_MONEY_LESS,{call:netNotifyUserMoneyLess,forever:true});
		}
		
		override public function leave():void
		{
			NetFacade.i.rcall(TableGroup.MDM_GR_STATUS, TableGroup.SUB_GR_TABLE_STATUS);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_SEND_CARD);
			NetFacade.i.rcall(UserGroup.MDM_GR_USER, UserGroup.SUB_GR_USER_STATUS);
			NetFacade.i.rcall(UserGroup.MDM_GR_USER, UserGroup.SUB_GR_USER_SCORE);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_LAND_SCORE);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_PASS_CARD);
			
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_GAME_START);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_DOUBLE_SCORE);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_OUT_CARD);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_GAME_END);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_USER_DOUBLE);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_BRIGHT_CARD);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_BRIGHT_START);
			NetFacade.i.rcall(GameGroup.MDM_GF_GAME, GameGroup.SUB_S_MULTIPLE);
			NetFacade.i.rcall(UserGroup.MDM_GR_USER,UserGroup.SUB_GR_USER_SUPPLY_APPLY_SUC);
			NetFacade.i.rcall(RoomGroup.MDM_GR_SERVER_INFO,RoomGroup.SUB_GR_RUNINFO);
			NetFacade.i.rcall(UserGroup.MDM_GR_USER,UserGroup.SUB_GR_USER_SUPPLY_NEED);
		}
		
		override public function update(lastTime:int):void
		{
		}
		
		public function showDisplayObject(obj:*, visible:Boolean=true):void
		{
			if(obj is DisplayObject)
				obj.visible = visible;
			else if(obj is Array)
			{
				for(var i:uint=0;i<obj.length;i++)
				{
					if(obj[i])
						obj[i].visible = visible;
				}
			}
			else
			{
				obj.visible = visible;
			}
		}
		
		protected function netRequestLandScore(score:uint):void
		{
			NetFacade.i.send(FrameGroup.MDM_GF_FRAME, FrameGroup.SUB_GF_USER_READY, score);
		}
		protected function netRequestReady():void
		{
			NetFacade.i.send(GameGroup.MDM_GF_GAME, GameGroup.SUB_C_LAND_SCORE);
		}
		protected function netRequestPassCard():void
		{
			NetFacade.i.send(GameGroup.MDM_GF_GAME, GameGroup.SUB_C_PASS_CARD);
		}
		protected function netNofityTableStatus(...parms):void
		{
			
		}
		protected function netNofityUserStatus(...parms):void
		{
			
		}
		protected function netNofityUserScore(...parms):void
		{
			
		}
		protected function netNofitySendCard(...parms):void
		{
			
		}
		protected function netNofityLandScore(...parms):void
		{
			
		}
		protected function netNofityGameStart(...parms):void
		{
			
		}
		protected function netNofityOutCard(...parms):void
		{
			
		}
		protected function netNofityPassCard(...parms):void
		{
			
		}
		protected function netNofityGameEnd(...parms):void
		{
			
		}
		protected function netNofityBrightStart(...parms):void
		{
			
		}
		protected function netNofityBrightCard(...parms):void
		{
			
		}
		protected function netNofityPlayerTrustee(...parms):void
		{
			
		}
		protected function netNofityDoubleScore(...parms):void
		{
			
		}
		protected function netNofityUserDouble(...parms):void
		{
			
		}
		protected function netNofityMultiple(...parms):void
		{
			
		}
		protected function netNotifyUserSupplyApplySuc(...parms):void
		{
			
		}
		protected function netReplyRunInfo(...parms):void
		{
			
		}
		protected function netNotifyUserSupplyNeed(...parms):void
		{
			
		}
		public function netNotifyUserMoneyLess(...parms):void
		{
			
		}
		
		public function playSound(id:String):void
		{
			SoundManager.i.play(id);
		}
	}
}